package com.shntec.xtask.dao;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

import com.shntec.bp.common.BaseSQLHelper;
import com.shntec.bp.common.ShntecBaseDAO;
import com.shntec.bp.util.ShntecLogger;

public class XtaskQuestionObject extends ShntecBaseDAO{
	
	private final static String THIS_TABLE_NAME = "xtask_tasks";
	private final static String THIS_PRIMARY_KEY_NAME = "tid";
	
	private Integer qid = null;
	private Integer tid = null;
	private String content = null;
	private Long createTime = null;
		
	public XtaskQuestionObject(BaseSQLHelper helper){
		super(helper);
		tableName = THIS_TABLE_NAME;
		primaryKeyName = THIS_PRIMARY_KEY_NAME;
	}
	
	public Integer getQid() {
		return qid;
	}

	public void setQid(Integer qid) {
		this.qid = qid;
	}

	public Integer getTid() {
		return tid;
	}

	public void setTid(Integer tid) {
		this.tid = tid;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
	}

	@Override
	protected boolean loadResultSet(ResultSet rs) {
		try {
			
			qid = rs.getInt("qid");
			tid = rs.getInt("tid");
			content = rs.getString("content");
			createTime = rs.getLong("createtime");

		} catch (SQLException e) {
			ShntecLogger.logger.error("Handle database resultset failed, table name=" + getTableName());
			ShntecLogger.logger.error(e.getMessage());
			return false;
		}
		
		return true;
	}

	@Override
	protected HashMap<String, Object> generateColumnList() {
		HashMap<String, Object> columnList = new HashMap<String, Object>();
		
		columnList.put("qid", qid);
		columnList.put("tid", tid);
		columnList.put("content", content);
		columnList.put("createtime", createTime);
		
		return columnList;
	}

	@Override
	protected void updateResultSet(ResultSet rs) throws SQLException {
		
		updateAllowNullColumns(rs, "tid", tid);
		
		updateAllowNullColumns(rs, "content", content);

		updateNotAllowNullColumns(rs, "createtime", createTime);
		
		
	}
	
	
}
